<!DOCTYPE html>
<html>
<head>
	<!--@淘宝小赢家 http://web101.taobao.com -->
	<title><{$_title}></title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
<script src="bootstrap/js/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
<{include file='layouts/headNav.html'}>
<div class="container-fluid">
<div class="row-fluid">
	<div class="span2">
		<{include file='layouts/leftNav.html'}>
		<!--Sidebar content-->
	</div>
	<div class="span10">
		<!--Body content-->
		<ul class="nav nav-tabs">
			<li class="active"><a href="<{spUrl c=$_controller a=search}>">记录列表</a></li>
			<li><a href="<{spUrl c=$_controller a=create}>">新增记录</a></li>
		</ul>
		<{if $_attributeFormset}>
		<form method="post" action="<{spUrl c=$_controller a=search}>">
			<table>
			<tr>
				<{foreach from=$_attributes key=key item=attribute}>
				<{if $_attributeFormset&& isset($_attributeFormset[$key]) && $_attributeFormset[$key]['type'] == 'textField'}>
				<td><{$attribute}>
				<{cbForm moreParams=$_attributeFormset[$key] name="`$_controller`[`$key`]"}>							
				<input type="hidden" name="<{$_controller}>_searchType[<{$key}>]" value="0"/>
				</td>
				<{/if}>
				<{/foreach}>
				<td>&nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary">开始查询</button></td>
				<!--<button type="reset" class="btn">清除重填</button>-->
			</tr>
			</table>
		</form>
		<{/if}>
		
		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<{foreach from=$_attributes item=attribute}>
					<th><{$attribute}></th>
					<{/foreach}>
					<th width="150px">操作</th>
				</tr>
			</thead>
			<tbody>
			<{if !empty($tpl_datas)}>
			
				<{foreach from=$tpl_datas item=data}>
				<tr>
					<{foreach from=$_attributes key=key item=attribute}>
					<td>
						<{if isset($_attributeFormset) && isset($_attributeFormset[$key]) && ($_attributeFormset[$key]['type']|strtolower == 'dropdownlist' || $_attributeFormset[$key]['type']|strtolower == 'radio')}>
						<{$_attributeFormset[$key]['options'][$data[$key]]}>
						<{else}>
						<{$data[$key]}>
						<{/if}>
					</td>
					<{/foreach}>
					<td>
						<div class="btn-toolbar">
							<div class="btn-group">
								<a class="btn" href="<{spUrl c=$_controller a=view id=$data[$_pk]}>"><i class="icon-search"></i></a>
								<a class="btn" href="<{spUrl c=$_controller a=update id=$data[$_pk]}>"><i class="icon-pencil"></i></a>
								<a class="btn deleteConfirm" href="<{spUrl c=$_controller a=delete id=$data[$_pk]}>"><i class="icon-remove-sign"></i></a>
							</div>
						</div>
					</td>
				</tr>
				<{/foreach}>

				<{else}>
				<tr><td colspan=<{count($_attributes) + 1}>>暂无记录！</td></tr>
				<{/if}>
			</tbody>
		</table>
		
		<{if !empty($tpl_pager)}>
		<div class="rows">
			<div class="span6">
				<div class="pagination pagination-right">
					<ul>
						<li><a data="<{$tpl_pager['prev_page']}>" href="#">«</a></li>
						<{foreach from=$tpl_pager['all_pages'] item=page}>
						<{if $page > 10}>
							<{if $tpl_page > $page}>
							<li class="active"><a data="<{$tpl_page}>" href="#"><{$tpl_page}></a></li>
							<{/if}>
							<{if $tpl_page < $tpl_pager['last_page']}>
							<li><a data="<{$tpl_pager['last_page']}>" href="#"><{$tpl_pager['last_page']}></a></li>
							<{/if}>
							<{break}>
						<{/if}>
						<li <{if $page eq $tpl_page}>class="active"<{/if}>><a data="<{$page}>" href="#"><{$page}></a></li>
						<{/foreach}>
						<li><a data="<{$tpl_pager['next_page']}>" href="#">»</a></li>
					</ul>
				</div>
			</div>
			<div class="span6" style="height:75px; line-height: 68px;">
				<form method="post" action="<{spUrl c=$_controller a=search}>" class="form-search pageForm">
					<{if !empty($tpl_keyword)}>
					<{foreach from=$tpl_keyword key=key item=value}>
					<input name="<{$_controller}>[<{$key}>]" type="hidden" />
					<{/foreach}>
					<{/if}>
					<{if !empty($tpl_searchType)}>
					<{foreach from=$tpl_searchType key=key item=value}>
					<input name="<{$_controller}>_searchType[<{$key}>]" type="hidden" />
					<{/foreach}>
					<{/if}>
					<input name="page" type="text" class="input-mini search-query" value="<{$tpl_page}>">
					<button type="submit" class="btn">Go</button>
				</form>
			</div>
		</div>
		<{/if}>
		<{if !empty($tpl_keyword)}>
		<{foreach from=$tpl_keyword key=key item=value}>
		<script>jQuery('[name="<{$_controller}>[<{$key}>]"]').val('<{$value}>');</script>
		<{/foreach}>
		<{/if}>
		<{if !empty($tpl_searchType)}>
		<{foreach from=$tpl_searchType key=key item=value}>
		<script>jQuery('[name="<{$_controller}>_searchType[<{$key}>]"]').val('<{$value}>');</script>
		<{/foreach}>
		<{/if}>
	</div>
</div>
</div>
<script>
(function($){
	$('.deleteConfirm').click(function(){
		if(confirm('您确认删除该条记录吗？该操作不可逆。'))
			return true;
		else
			return false;
	})
	$('.pagination ul li').click(function(){
		$('.pageForm [name="page"]').val($(this).find('a').attr('data'));
		$('.pageForm').submit();
		return false;
	})
})(jQuery)
</script>
<!--@淘宝小赢家 http://web101.taobao.com -->
</body>
</html>